Test Series - Data Structure

Test Number 80/115

Q: The leaves of an expression tree always contain?
A. operators
B. operands
C. null
D. expression
Solution: The leaves of an expression tree always contain the result of a given expression (i.e.) operands.
Q: A node can have a minimum of one child.
A. true
B. false
C. none
D. blank
Solution: It is possible for a node to have at least one child, as is the case with the unary minus operator.
Q: What does the other nodes of an expression tree(except leaves) contain?
A. only operands
B. only operators
C. both operands and operators
D. expression
Solution: The nodes other than leaves always contain only operators. There cannot be any operand in those nodes.
Q: An expression tree is a kind of?
A. Binary search tree
B. Fibonacci tree
C. Binary tree
D. Treap
Solution: The expression tree is a binary tree. It contains operands at leaf nodes and remaining nodes are filled with operators. The operands and the operators can be arranged in any order (ascending, descending).
Q: The expression obtained by recursively producing a left expression, followed by an operator, followed by recursively producing a right expression is called?
A. prefix expression
B. infix expression
C. postfix expression
D. paranthesized expression
Solution: It is an infix expression because the format of an infix expression is given by operand-operator-operand.
Q: The average depth of a binary tree is given as?
A. O(N)
B. O(log N)
C. O(M log N)
D. O(√N)
Solution: The average depth of a binary expression tree is mathematically found to be O(√N).
Q: An expression tree is created using?
A. postfix expression
B. prefix expression
C. infix expression
D. paranthesized expression
Solution: A postfix expression is converted into an expression tree by reading one symbol at a time and constructing a tree respectively.
Q: ++a*bc*+defg is an?
A. postfix expression
B. infix expression
C. prefix expression
D. invalid expression
Solution: It is a prefix expression obtained from a preorder traversal since it is of the form operator-operand-operand.
Q: An expression tree’s nodes can be deleted by calling?
A. malloc
B. calloc
C. delete
D. free
Solution: In Binary trees, nodes are created by calling malloc and they are deleted by calling free.
Q: In an expression tree algorithm, what happens when an operand is encountered?
A. create one node pointing to a stack
B. pop the nodes from the stack
C. clear stack
D. merge all the nodes
Solution: When an operand is encountered, create one node trees and push it on to the stack. When an operator is encountered, pop the pointers from last two trees from the stack.

You Have Score    /10